package com.gson.bean;

import com.gson.token.tokenStorager.TokenStorager;
import com.gson.token.tokenStorager.TokenStoragerFactory;
import com.gson.token.tokenStorager.tokenStoragerImpl.TokenStoragerRides;
import com.gson.util.ConfKit;

/**
 * @Company 陕西识代运筹信息科技股份有限公司
 * @Discription
 * @Author houfengli
 * @CreateDate 2017/2/17 14:18
 * @Version 1.0
 */
public class WeixinAccount {
    private String appId;
    private String secret;
    private String encodingAesKey;
    private String token;
    private TokenStorager tokenStorager;

    private static volatile  WeixinAccount weixinAccount;

    public static WeixinAccount getWeixinAccount(){
        if (weixinAccount == null) {
            synchronized (WeixinAccount.class) {
                if (weixinAccount == null) {
                    weixinAccount = new WeixinAccount(TokenStoragerRides.class);
                }
            }
        }
        return weixinAccount;
    }
    private WeixinAccount(){}

    private WeixinAccount(Class TokenStorager){
        String encodingAesKey= ConfKit.get("encodingAesKey");
        String token= ConfKit.get("token");
        String AppId= ConfKit.get("AppId");
        String secret= ConfKit.get("AppSecret");

        this.appId = AppId;
        this.secret = secret;
        this.encodingAesKey = encodingAesKey;
        this.token = token;

        TokenStorager storager = TokenStoragerFactory.createTokenStorager(TokenStorager);
        this.tokenStorager = storager;
    }

    public TokenStorager getTokenStorager() {
        return tokenStorager;
    }

    public String getAppId() {
        return appId;
    }

    public String getSecret() {
        return this.secret;
    }

    public String getEncodingAesKey() {
        return encodingAesKey;
    }

    public String getToken() {
        return token;
    }
}
